package com.smartian.scan.filesearch.impl.callbacks;

import android.util.Log;

import com.smartian.scan.filesearch.bean.PathFile;
import com.smartian.scan.filesearch.interfaces.ISearchCallback;

import java.util.List;
import java.util.concurrent.atomic.AtomicLong;

public class LogOpCallback implements ISearchCallback {

    private final String TAG = "Search_LogOp";
    private long startTimeout = 0l;

    private AtomicLong mFileCounter = new AtomicLong(0);

    @Override
    public void onStartSearch() {
        startTimeout = System.currentTimeMillis();
        Log.e(TAG,"开始检索文件");
    }

    @Override
    public void onFile(List<PathFile> files) {
        for (PathFile f : files){
            mFileCounter.incrementAndGet();
            Log.i(TAG,"检索到文件："+f.getAbsolutePath());
        }

    }

    @Override
    public void onStopSearch() {
       long dxTime =  (System.currentTimeMillis()-startTimeout);
        Log.e(TAG,"停止检索文件，总共发现 "+mFileCounter.get()+"个文件，耗时："+dxTime+"ms");
    }

    @Override
    public void onError(String path,Throwable throwable) {
        Log.e(TAG,"检索文件出错："+path);
    }
}
